iB Pro v32 Arcade Game Compatibility

If you want a improved 'iB "Pro" Arcade - Mass Game Import' function you also has to edit the arcadeadmin.php file.
This improvement also copies the gamedata folder in the tar package.
Note that the empty file v32game.txt is not copied (nor an empty index.html, if there are any).
This doesn't matter if you use my plugin since that file isn't checked anyway.

How to do it:
Import the attached file 'iB Pro v32 Arcade Game Compatibility.xml' as a plugin.
(Via "Plugin & Products" > "Download / Upload Plugins" > "Import Plugin Definitions XML File" in your Admin CP.)

Create the folder "arcade" in the forum root.
Create the folder "gamedata" in the newly created "arcade" folder and CHMOD it to 777.

Edit the file admincp/arcadeadmin.php
Warning! Copy the original arcadeadmin.php first, just in case...
You are doing this at your own risk. This will copy and delete files on your server. Don't blame me if anything goes wrong.

FIND:
		@unlink($image_path . '/' . $thisgame['shortname'] . '1.gif');
		@unlink($image_path . '/' . $thisgame['shortname'] . '2.gif');
		@unlink($game_path . '/' . $thisgame['shortname'] . '.swf');

BELOW IT ADD:

// Addition for uninstalling IBPro v32 games!
// Tries to delete the game folder in arcade/gamedata/ 
// 2007-10-28 /SK	
		foreach( glob('arcade/gamedata/' . $thisgame['shortname'] . '/*.*') as $sk_fn)
		{
			@unlink( $sk_fn );
		}
		rmdir( 'arcade/gamedata/' . $thisgame['shortname'] );
// End. Addition fr uninstalling IBPro v32 games 


FIND:
		if (substr($filename, strlen($filename)-4, 4) == '.tar')
		{
			$gametar = new tar;
			if ($gametar->openTAR($vbulletin->GPC['filepath'] . '/' . $filename))
			{
				foreach ($gametar->files as $key => $val)
				{

BELOW IT ADD:

// Addition for installing IBPro v32 games!                                                                                
// If there is a folder called gamedata in the tar it will copy all files in there to the forumroot/arcade/gamedata folder 
// 2007-10-28 /SK                                                                                                          
					if( ($startpathpos = strpos( $val['name'], 'gamedata/')) !== false )
					{	
						$newpath = $real_path . '/../../arcade/gamedata';
						$startpathpos += 9;
						while( ($endpathpos = strpos( $val['name'], '/', $startpathpos )) != 0 )
						{
							$newpath .= '/' . substr( $val['name'], $startpathpos, $endpathpos - $startpathpos );
							@mkdir($newpath , 0777);
							
							$startpathpos = $endpathpos + 1;
						}
						
						$newfile = $newpath . '/' . substr( $val['name'], $startpathpos );
		
						if ($handle = fopen($newfile, "wb") )
						{
							fputs($handle, $val['file'], strlen($val['file']));
							fclose($handle);
						}			
					}
// End. Addition fr installing IBPro v32 games 

Done!

I don't guarantee this work for every v32 game. But it seems to work for many anyway.
